<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .operation-menu a{
        margin: 5px 0;!important;
    }
    #tooltip{
        position:absolute;
        border:1px solid #ccc;
        background:#333;
        padding:2px;
        display:none;
        color:#fff;
    }
    /*.layui-form select{*/
        /*display: inline-block;*/
    /*}*/
</style>
<body>
    <div class="layui-fluid main">
        <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
                <div class="layui-form-item" style="float: left;">
                    <form class="layui-form serch" action="{:url('admin/Channel/index')}" method="post">
                        <div class="layui-form-item" style="float: left;">

                            <a href="{:url('admin/Channel/add')}" class="layui-btn layui-btn-sm a_menu">
                                添加渠道
                            </a>

                        </div>
                    </form>

                </div>
        </fieldset>
        <table class="layui-table" lay-even="" lay-skin="line">
            <colgroup>
                <!--<col width="8%">-->
                <!--<col width="8%">-->
                <!--<col width="8%">-->
                <!--<col width="8%">-->
                <!--<col width="8%">-->
                <col width="10%">
                <col width="15%">
                <col width="15%">
                <col width="15%">
                <col width="15%">
                <col width="15%">
                <col width="15%">
                <!--<col width="9%">-->
                <!--<col width="9.3%">-->
                <!--<col width="9.3%">-->
                <!--<col width="5%">-->
                <!--<col width="10%">-->
            </colgroup>
            <thead>

            <tr>
                <th>渠道编号</th>
                <th>渠道名称</th>
                <th>创建时间</th>
                <th>修改时间</th>
                <th>渠道状态</th>
                <th>操作人员</th>
                <!--<th>开始时间</th>-->
                <!--<th>结束时间</th>-->
                <!--<th>发布人员</th>-->
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
{volist name='data' id='vo'}
            <tr>
                <td>{$vo.channel_id}</td>
                <td>{$vo.name}</td>
                <td >
                    {$vo.creationtime|date='Y-m-d H:i:s',###}
                </td>
                <td >
                    {$vo.updatetime|date='Y-m-d H:i:s',###}
                </td>



                <td>
                    <?php if($vo['state']=='0'){
                   echo "已启用";
                    }else{
                  echo '已禁用';
                    }?>
                </td>
                <td >
                    {$vo.admin.nickname}
                </td>
                <td class="operation-menu">
                    <a href="{:url('admin/Channel/edit')}?id={$vo.channel_id}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: darkslategrey">编辑</a>
                    {switch name="vo.state"}
                    {case value="0"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$vo.state}"  codeid="{$vo.channel_id}" style="margin-right: 0;font-size:12px;">禁用</a>{/case}
                    {case value="1"} <a href="####" class="layui-btn layui-btn-xs layui-btn-danger shelves" data-id="{$vo.state}" codeid="{$vo.channel_id}" style="margin-right: 0;font-size:12px;">启用</a>{/case}
                    {default /}default
                    {/switch}

                </td>
            </tr>
{/volist}
            </tbody>
        </table>
    <div>{$data->render()}</div>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>

        <script>




            var message;
            layui.config({
                base: '__JS__/',
                version: '1.0.1'
            }).use(['app', 'message'], function() {
                var app = layui.app,
                    $ = layui.jquery,
                    layer = layui.layer;
                //将message设置为全局以便子页面调用
                message = layui.message;
                //主入口
                app.set({
                    type: 'iframe'
                }).init();
            });
        </script>
        <script type="text/javascript">

            $('.delete').click(function(){
                var id = $(this).attr('codeid');
                layer.confirm('确定要删除?', function(index) {
                    $.ajax({
                        url:"{:url('admin/coupon/delcoupon')}",
                        data:{id:id},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500)
                            }
                        }
                    })
                })
            })
            $('.shelves').click(function(){
                var id = $(this).attr('codeid');
                var state= $(this).attr('data-id');
                layer.confirm('是否确定操作？', function(index) {
                    $.ajax({
                        url:"{:url('admin/Channel/del')}",
                        data:{id:id,state:state},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500)
                            }
                        }
                    })
                })
            })



            // $('.copy').click(function(){
            //     var id = $(this).attr('codeid');
            //     layer.confirm('确定复制吗?', function(index) {
            //         $.ajax({
            //             url:"{:url('admin/trip/copytrip')}",
            //             data:{id:id},
            //             success:function(res) {
            //                 layer.msg(res.msg);
            //                 if(res.code == 1) {
            //                     setTimeout(function(){
            //                         location.reload();
            //                     },1500)
            //                 }
            //             }
            //         })
            //     })
            // })

        </script>
        <script type="text/javascript">
            layui.use('layer', function(){
                var layer = layui.layer;
                $('.a_menu').click(function(){
                    var url = $(this).attr('href');
                    var a = 0;
                    $.ajax({
                        url:url
                        ,async:false
                        ,success:function(res){
                            if(res.code == 0) {
                                layer.msg(res.msg);
                                a = 1;
                            }
                        }
                    })
                    if(a === 0) {
                        layer.open({
                            type:2,
                            content:url,
                            area: ['450px', '300px'],

                            end:function(){
                                location.reload();
                            }
                        });
                    }
                    return false;
                })

                $('.preview').click(function(){
                    var url = $(this).attr('href');
                    layer.open({
                        type:2,
                        content:url,
                        area: ['550px', '400px']
                    });
                    return false;
                })
            });
        </script>

</body>
</html>
